using UnityEngine;

namespace Script.CreatureEditor
{
	public class EditorAction
	{
		protected EditorController editor;

		protected string[] parents;

		public EditorAction(EditorController editorController)
		{
			editor = editorController;
		}

		public virtual void End()
		{
		}

		public virtual void Update()
		{
		}

		protected bool HalfOfTheScreen()
		{
			return Input.mousePosition.x > (float)(Screen.width / 2);
		}

		protected Transform WskazanyObiekt()
		{
			return Physics2D.Raycast(WskazanyPunkt(), Vector2.down, 1f).transform;
		}

		protected Vector3 WskazanyPunkt()
		{
			Vector3 mousePosition = Input.mousePosition;
			mousePosition.z = -10f;
			Vector3 vector = Camera.main.ScreenToWorldPoint(mousePosition);
			return new Vector3(vector.x, vector.y, 0f);
		}

		protected RaycastHit WskazaneMiejsce(Vector2 punkt)
		{
			punkt.x = 0f;
			RaycastHit hitInfo;
			Physics.Raycast(punkt, Vector2.right, out hitInfo, 100f);
			return hitInfo;
		}

		protected void Obrot(Transform obiekt, Vector3 punkt)
		{
			Vector3 vector = punkt - obiekt.position;
			if (vector != Vector3.zero)
			{
				float angle = Mathf.Atan2(vector.y, vector.x) * 57.29578f;
				obiekt.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
			}
		}
	}
}
